<?php
namespace Home\Controller;
use Think\Controller;

/**
 * 数据中心控制器
 */
class DataCenterController extends BaseController {

    /**
     * 站点数据中心接口（通知失败、已到站、拒收件、本月已提货）
     * @again quyang 2017-1-21
     * @autho cheng
     */
    public function queryOrderCourier() {
        $param = I('param.');
        empty($param['courierId']) && $this->param_error(); //快递员ID必填
        
        $page = !empty($param['currentPage']) ? $param['currentPage'] : 1; //当前页
        $nums = !empty($param['pageSize']) ? $param['pageSize'] : 10; //页大小

        if (empty($param['date'])){
            $param['date'] = date('Ym');
        }
        $parcelService = new \Home\Server\ParcelService();
        $count = $parcelService->countExpressStorage($param['courierId'],$param['combinedNo'],$param['date'],$param['state']);

        //通知中通知失败数量显示
        $noticeIng = $parcelService->countExpressStorage($param['courierId'],$param['combinedNo'],$param['date'],2);
        $noticeFail = $parcelService->countExpressStorage($param['courierId'],$param['combinedNo'],$param['date'],5);

        $list = $parcelService->getExpressStorage($param['courierId'],$param['combinedNo'],$param['date'],$param['state'],$page,$nums);

        $noticeIng == false ? $noticeIng = '0' : $noticeIng;
        $noticeFail == false ? $noticeFail = '0' : $noticeFail;
        $count == false ? $count = '0' : $count;
        $list == false ? $list = array() : $list;

        $data['noticeIng'] = $noticeIng;
        $data['noticeFail'] = $noticeFail;
        $data['totalPage'] = ceil($count/$nums);;
        $data['totalCount'] = $count;
        $data['packetInfoList'] = $list;
        $this->output($status = 1, $data);
    }
    
    

}
